package ru.xpparty.scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Grab
 * Date: 19.12.10
 * Time: 14:46
 * To change this template use File | Settings | File Templates.
 */
public class PortRange {
    private int start;
    private int end;

    public PortRange(int start, int end) {
        checkPort(start);
        checkPort(end);
        this.start = start;
        this.end = end;
    }

    public PortRange(int port) {
        checkPort(port);
        start = port;
        end = port;
    }

    private void checkPort(int port) {
        if (isValid(port))
            throw new InvalidPortException();
    }

    private boolean isValid(int port) {
        return port < 0 || port > 65535;
    }

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }
}
